package com.cruise.biztest2.controller;

import com.cruise.biztest2.api.feign.FeignBiztest2Api;
import com.cruise.biztest2.api.pojo.entity.LcnDemo;
import com.cruise.biztest2.api.pojo.entity.LcnDemo2;
import com.cruise.biztest2.service.LcnDemo2Service;
import com.cruise.common.web.ex.BizException;
import com.cruise.common.web.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 类名：HelloController
 * 描述：TODO
 * @author cruise
 * 日期：2021/1/15 下午9:02
 * 版本：1.0
 **/
@Api(tags = "你好")
@RestController
@RequestMapping("/biztest2/hello")
public class HelloController implements FeignBiztest2Api {

    @Resource
    private LcnDemo2Service lcnDemo2Service;

    @ApiOperation(value = "向客人问好")
    @GetMapping("/sayHi")
    public ResponseEntity<String> sayHi(@RequestParam("name")String name){
        return ResponseEntity.ok("Hi:"+name);
    }


    @ApiOperation(value = "保存 LcnDemo2")
    @PostMapping("/addLcnDemo2")
    @Override
    public Result<LcnDemo> addLcnDemo2(LcnDemo2 lcnDemo2) {

        lcnDemo2Service.addLcnDemo2(lcnDemo2);
        return Result.success();
    }

    @ApiOperation(value = "异常测试 ")
    @PostMapping("/exTest")
    public Result<LcnDemo> exTest() {

        throw new BizException("889");
    }
}
